home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tcl / dist6.3 / config < prev    next >
Encoding:
Text File  |  1992-03-19  |  9.6 KB  |  320 lines

  1. #!/bin/csh -f
  2. #
  3. # This script should be executed to configure the Tcl source directory
  4. # for a particular system.  It probes the system for various header
  5. # files and library object files.  Where things needed by Tcl are missing,
  6. # substitute versions are included from the "compat" subdirectory.
  7. #
  8. # $Header: /user6/ouster/tcl/RCS/config,v 1.28 92/03/19 08:22:22 ouster Exp $ SPRITE (Berkeley)
  9. #
  10. # Copyright 1991, 1992 Regents of the University of California
  11. # Permission to use, copy, modify, and distribute this
  12. # software and its documentation for any purpose and without
  13. # fee is hereby granted, provided that this copyright
  14. # notice appears in all copies.  The University of California
  15. # makes no representations about the suitability of this
  16. # software for any purpose.  It is provided "as is" without
  17. # express or implied warranty.
  18.  
  19. #--------------------------------------------------------------
  20. # The variable definitions below configure this script:  they
  21. # tell where system-defined things are kept (so this program
  22. # can tell whether the system contains certain features needed
  23. # by Tcl), and they indicate which Tcl files to modify to
  24. # reflect the configuration.
  25.  
  26. # Directory containing system include files:
  27.  
  28. set includeDir="/usr/include"
  29.  
  30. # Archive file containing object code for standard C library:
  31.  
  32. set libc="/lib/libc.a"
  33.  
  34. # Makefile to modify:
  35.  
  36. set makefile="Makefile"
  37.  
  38. # Header file to modify to hold #defines about system configuration:
  39.  
  40. set config="tclUnix.h"
  41. #--------------------------------------------------------------
  42.  
  43. set changes=0
  44. unset time
  45.  
  46. # First make sure that the configuration variables have been
  47. # set in a reasonable fashion.
  48.  
  49. if ( ! -r $includeDir/stdio.h ) then
  50.     echo "- ERROR\!\! $includeDir doesn't seem to contain standard system"
  51.     echo "  include files.  Please edit config to set the includeDir"
  52.     echo "  variable."
  53.     exit(1)
  54. endif
  55. if ( ! -r $libc ) then
  56.     echo "- ERROR\!\! C library $libc doesn\'t exist.  Please edit config"
  57.     echo "  to set the libc variable."
  58.     exit(1)
  59. endif
  60. nm -p $libc > tmp.libc
  61. if ( $status != 0 ) then
  62.     echo "- ERROR\!\!  Nm failed to extract names of system-supplied library"
  63.     echo "  procedures from $libc.  You'll have to modify config by hand to"
  64.     echo "  fix the problem (whatever it is)."
  65.     exit(1)
  66. endif
  67.  
  68. # Since nm produces different output on different machines, the code
  69. # below attempts to guess what pattern to grep for in the nm output.
  70.  
  71. set pattern="[ADIT]"
  72. set x=`grep printf tmp.libc | grep -c CODE`
  73. if ( $x ) then
  74.     set pattern=CODE
  75. endif
  76. set x=`grep printf tmp.libc | grep -c extern`
  77. if ( $x ) then
  78.     set pattern="|extern|"
  79. endif
  80.  
  81. # Check in the C library for particular library procedures and
  82. # variables needed by Tcl.
  83.  
  84. set gettod=`grep gettimeofday tmp.libc | grep -c "$pattern"`
  85. if ( $gettod > 1 ) set gettod=1
  86. set getwd=`grep getwd tmp.libc | grep -c "$pattern"`
  87. if ( $getwd > 1 ) set getwd=1
  88. set opendir=`grep opendir tmp.libc | grep -c "$pattern"`
  89. if ( $opendir > 1 ) set opendir=1
  90. set strerror=`grep strerror tmp.libc | grep -c "$pattern"`
  91. if ( $strerror > 1 ) set strerror=1
  92. set strstr=`grep strstr tmp.libc | grep -c "$pattern"`
  93. if ( $strstr > 1 ) set strstr=1
  94. set strtod=`grep strtod tmp.libc | grep -c "$pattern"`
  95. if ( $strtod > 1 ) set strtod=1
  96. set strtol=`grep strtol tmp.libc | grep -c "$pattern"`
  97. if ( $strtol > 1 ) set strtol=1
  98. set strtoul=`grep strtoul tmp.libc | grep -c "$pattern"`
  99. if ( $strtoul > 1 ) set strtoul=1
  100. set sys_errlist=`grep sys_errlist tmp.libc | grep -c "$pattern"`
  101. if ( $sys_errlist > 1 ) set sys_errlist=1
  102. \rm tmp.libc
  103.  
  104. # Next, install header files that aren't present in /usr/include.
  105.  
  106. set extraHdrs=""
  107. foreach i (dirent.h limits.h)
  108.     \rm -f $i
  109.     if ( ! -r $includeDir/$i ) then
  110.     cp compat/$i .
  111.     set extraHdrs="$extraHdrs $i"
  112.     endif
  113. end
  114. set stdlibOK=0
  115. \rm -f stdlib.h
  116. if ( -r $includeDir/stdlib.h ) then
  117.     # The check below is needed because SunOS has a stdlib that
  118.     # doesn't declare strtod and other procedures, so we have to
  119.     # use ours instead.
  120.  
  121.     set chk1=`grep -c strtol $includeDir/stdlib.h`
  122.     set chk2=`grep -c strtoul $includeDir/stdlib.h`
  123.     set chk3=`grep -c strtod $includeDir/stdlib.h`
  124.     if ( $chk1 > 0 && $chk2 > 0 && $chk3 > 0 ) then
  125.     set stdlibOK=1
  126.     endif
  127. endif
  128. if ( ! $stdlibOK ) then
  129.     cp compat/stdlib.h .
  130.     set extraHdrs="$extraHdrs stdlib.h"
  131. endif
  132.  
  133. # Even if string.h exists it's not complete on all systems.  If
  134. # some of the procedures we need are missing from the library, then
  135. # also install a Tcl-specific string.h.
  136.  
  137. \rm -f string.h
  138. if ( ! $strstr || ! $strtoul || ! -r $includeDir/string.h ) then
  139.     cp compat/string.h .
  140.     set extraHdrs="$extraHdrs string.h"
  141. endif
  142. if ( "$extraHdrs" != "" ) then
  143.     echo "- Substitutes will be used for the following header files,"
  144.     echo "  which aren't in ${includeDir} or aren't complete:"
  145.     echo "     $extraHdrs"
  146.     set changes=1
  147. endif
  148.  
  149. # Even if strtoul exists, it is bogus on some AIX systems.  Detect
  150. # this and pretend the system version doesn't exist if it's bogus.
  151.  
  152. if ( $strtoul ) then
  153.     cp compat/teststrtoul.c test.c
  154.     make test >& /dev/null
  155.     if ( $status == 0 ) then
  156.     a.out
  157.     if ( $status != 0 ) then
  158.         set strtoul=0
  159.     endif
  160.     endif
  161.     \rm -f a.out test.c
  162. endif
  163.  
  164. # Next, install C procedures for missing library functions.
  165.  
  166. set extraLibs=""
  167. \rm -f strerror.c
  168. if ( ! $strerror ) then
  169.     set extraLibs="$extraLibs strerror"
  170.     cp compat/strerror.c .
  171. endif
  172. \rm -f opendir.c
  173. if ( ! $opendir ) then
  174.     set extraLibs="$extraLibs opendir"
  175.     cp compat/opendir.c .
  176.     \rm -f dirent.h
  177.     cp compat/dirent2.h dirent.h
  178.     echo "- No opendir/readdir/closedir library exists in this system,"
  179.     echo "  so substitutes will be provided.  This system better have"
  180.     echo "  V7-style directories\!"
  181. endif
  182. \rm -f strstr.c
  183. if ( ! $strstr ) then
  184.     set extraLibs="$extraLibs strstr"
  185.     cp compat/strstr.c .
  186. endif
  187. \rm -f strtod.c
  188. if ( ! $strtod ) then
  189.     set extraLibs="$extraLibs strtod"
  190.     cp compat/strtod.c .
  191. endif
  192. \rm -f strtol.c
  193. if ( ! $strtol ) then
  194.     set extraLibs="$extraLibs strtol"
  195.     cp compat/strtol.c .
  196. endif
  197. \rm -f strtoul.c
  198. if ( ! $strtoul ) then
  199.     set extraLibs="$extraLibs strtoul"
  200.     cp compat/strtoul.c .
  201. endif
  202. if ( "$extraLibs" != "" ) then
  203.     echo "- Substitutes will be used for the following library procedures,"
  204.     echo "  which aren't in ${libc} or don't work correctly:"
  205.     echo "     $extraLibs"
  206.     set changes=1
  207. endif
  208.  
  209. # The following statements determine whether ranlib should be used
  210. # in the Makefile.  On System-V systems it shouldn't.  The only way
  211. # to figure this out is to run ranlib and see if it complains (ranlib
  212. # actually exists on some Sys-V systems, but it returns an error if
  213. # you run it).
  214.  
  215. set ranlibOK=0
  216. cat > ranlibtest.c << EOF
  217. #include <stdio.h>
  218. main (argc, argv)
  219.     int    argc;
  220.     char **argv;
  221. {
  222.     printf ("Hello, world.\n");
  223. }
  224. EOF
  225. cc -c ranlibtest.c
  226. ar cru ranlibtest.a ranlibtest.o
  227. ranlib ranlibtest.a >& /dev/null
  228. if ( $status == 0 ) then
  229.     set ranlibOK=1
  230. else
  231.     echo "- This system appears to be a System V one where ranlib isn't"
  232.     echo "  used.  The ranlib commands will be removed from Makefile."
  233.     set changes=1
  234. endif
  235. \rm -f ranlibtest.*
  236.  
  237. # Modify the Makefile to include supplemental library sources, if needed.
  238.  
  239. set compatObjs=""
  240. foreach i ($extraLibs)
  241.     set compatObjs="$compatObjs $i.o"
  242. end
  243. if ( ! -e $makefile.bak ) mv $makefile $makefile.bak
  244. if ( $ranlibOK ) then
  245.     sed -e "s/COMPAT_OBJS =/COMPAT_OBJS =$compatObjs/" $makefile.bak > $makefile
  246. else
  247.     sed -e "s/COMPAT_OBJS =/COMPAT_OBJS =$compatObjs/" \
  248.     -e "/ranlib/d" $makefile.bak > $makefile
  249. endif
  250.  
  251. # Set the #defines in tclUnix.h to provide various pieces of system
  252. # configuration information at compile time (existence of header files,
  253. # variables, type definitions, etc.)
  254.  
  255. if ( ! $gettod ) then
  256.     echo "- There's no gettimeofday in ${libc} so Tcl will use"
  257.     echo '  times for the "time" command.'
  258.     set changes=1
  259. endif
  260. if ( ! $getwd ) then
  261.     echo "- There's no getwd in ${libc} so Tcl will use"
  262.     echo '  getcwd for the "pwd" command.'
  263.     set changes=1
  264. endif
  265. set errlist=1
  266. if ( ! $sys_errlist && ! $strerror ) then
  267.     echo "- Neither strerror nor sys_errlist is defined in ${libc} so"
  268.     echo "  Tcl will make a guess about errno-related messages."
  269.     set errlist=0
  270.     set changes=1
  271. endif
  272. set sysTime=0
  273. if ( -r $includeDir/sys/time.h ) then
  274.     set sysTime=1
  275. endif
  276. set sysWait=0
  277. set unionWait=0
  278. if ( -r $includeDir/sys/wait.h ) then
  279.     set sysWait=1
  280.     cp compat/testwait.c test.c
  281.     make test >& /dev/null
  282.     if ( $status == 0 ) then
  283.     set unionWait=1
  284.     endif
  285.     \rm -f a.out test.c
  286. endif
  287. set pid_t=1
  288. cp compat/testpid.c test.c
  289. make test >& /dev/null
  290. if ( $status != 0 ) then
  291.     set pid_t=0
  292.     echo "- The type pid_t isn't defined in <sys/types.h> so Tcl will"
  293.     echo '  use "int" instead.'
  294. endif
  295. \rm -f a.out test.c
  296. set uid_t=1
  297. cp compat/testuid.c test.c
  298. make test >& /dev/null
  299. if ( $status != 0 ) then
  300.     set uid_t=0
  301.     echo "- The type uid_t isn't defined in <sys/types.h> so Tcl will"
  302.     echo '  use "int" instead.'
  303. endif
  304. \rm -f a.out test.c
  305. if ( ! -e $config.bak ) mv $config $config.bak
  306. set x=\.\*\$
  307. sed -e "s/define TCL_GETTOD 1/define TCL_GETTOD $gettod/" \
  308.     -e "s/define TCL_GETWD 1/define TCL_GETWD $getwd/" \
  309.     -e "s/define TCL_SYS_ERRLIST 1/define TCL_SYS_ERRLIST $errlist/" \
  310.     -e "s/define TCL_SYS_TIME_H 1/define TCL_SYS_TIME_H $sysTime/" \
  311.     -e "s/define TCL_SYS_WAIT_H 1/define TCL_SYS_WAIT_H $sysWait/" \
  312.     -e "s/define TCL_UNION_WAIT 1/define TCL_UNION_WAIT $unionWait/" \
  313.     -e "s/define TCL_PID_T 1/define TCL_PID_T $pid_t/" \
  314.     -e "s/define TCL_UID_T 1/define TCL_UID_T $uid_t/" \
  315. $config.bak > $config
  316.  
  317. if ( ! $changes ) then
  318.     echo "- No special modifications were needed for this system."
  319. endif
  320.